VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsDateConvert"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Public Function DateTimeStampToStringDate(ByVal dtDateTimeStampDate As String)

Dim dtStringDate
Dim dtStringDateYear
Dim dtStringDateMonth
Dim dtStringDateDay

dtStringDateYear = Right$(dtDateTimeStampDate, 4)
dtStringDateDay = Left$(dtDateTimeStampDate, 2)
dtStringDateMonth = Mid$(dtDateTimeStampDate, 4, 2)

dtStringDate = dtStringDateYear & dtStringDateMonth & dtStringDateDay

DateTimeStampToStringDate = dtStringDate

End Function

Public Function StringDateToDateTimeStamp(ByVal dtStringDate As String) As String
    
    StringDateToDateTimeStamp = DateSerial(Left$(dtStringDate, 4), Mid$(dtStringDate, 5, 2), Right$(dtStringDate, 2))
        
    StringDateToDateTimeStamp = CStr(StringDateToDateTimeStamp)
    
End Function

Public Function StringDateToLongDate(ByVal dtStringDate As String) As String

Dim dtDate As Date
Dim sNewDate As String
Dim nDay As Integer
Dim nMonth As Integer
Dim nYear As Integer
Dim sMonth As String
Dim intPos As Integer
 
intPos = InStr(1, dtStringDate, "/")

If intPos <> 0 Then
    dtDate = DateSerial(Right$(dtStringDate, 4), Mid$(dtStringDate, 4, 2), Left$(dtStringDate, 2))
Else
    dtDate = DateSerial(Left$(dtStringDate, 4), Mid$(dtStringDate, 5, 2), Right$(dtStringDate, 2))
End If

nDay = Day(dtDate)
nMonth = Month(dtDate)
nYear = Year(dtDate)
 
Select Case nMonth
    Case 1:    sMonth = "Jan"
    Case 2:    sMonth = "Feb"
    Case 3:    sMonth = "Mar"
    Case 4:    sMonth = "Apr"
    Case 5:    sMonth = "May"
    Case 6:    sMonth = "Jun"
    Case 7:    sMonth = "Jul"
    Case 8:    sMonth = "Aug"
    Case 9:    sMonth = "Sep"
    Case 10:    sMonth = "Oct"
    Case 11:    sMonth = "Nov"
    Case 12:   sMonth = "Dec"
End Select
 
sNewDate = CStr(nDay) & " " & sMonth & " " & CStr(nYear)

StringDateToLongDate = sNewDate
 
End Function

Public Function LongDateToStringDate(ByVal dtLongDate As String) As String

Dim dtStringDateYear As String
Dim dtStringDateMonth As String
Dim dtStringDateDay As String
Dim dtStringDate As String

dtStringDateYear = Right$(dtLongDate, 4)
dtStringDateMonth = Mid$(dtLongDate, 4, 3)
dtStringDateDay = Left$(dtLongDate, 2)

Select Case dtStringDateMonth
    Case "Jan"
        dtStringDateMonth = "01"
    Case "Feb"
        dtStringDateMonth = "02"
    Case "Mar"
        dtStringDateMonth = "03"
    Case "Apr"
        dtStringDateMonth = "04"
    Case "May"
        dtStringDateMonth = "05"
    Case "Jun"
        dtStringDateMonth = "06"
    Case "Jul"
        dtStringDateMonth = "07"
    Case "Aug"
        dtStringDateMonth = "08"
    Case "Sep"
        dtStringDateMonth = "09"
    Case "Oct"
        dtStringDateMonth = "10"
    Case "Nov"
        dtStringDateMonth = "11"
    Case "Dec"
        dtStringDateMonth = "12"
End Select

dtStringDate = dtStringDateYear & dtStringDateMonth & dtStringDateDay

LongDateToStringDate = dtStringDate

End Function

Public Function TimeStampDateToStringDate(ByVal dtDate As String)

Dim dtStringDate
Dim dtStringDateYear
Dim dtStringDateMonth
Dim dtStringDateDay

dtStringDateYear = Year(dtDate)
dtStringDateDay = Day(dtDate)
dtStringDateMonth = Month(dtDate)

If Len(dtStringDateDay) = 1 Then
    dtStringDateDay = "0" & dtStringDateDay
End If

If Len(dtStringDateMonth) = 1 Then
    dtStringDateMonth = "0" & dtStringDateMonth
End If

dtStringDate = dtStringDateYear & dtStringDateMonth & dtStringDateDay

TimeStampDateToStringDate = dtStringDate

End Function

Public Function ShortDateToStringDate(ByVal dtShortDate As String) As String

Dim dtStringDate

Dim dtShortDateMonth
Dim dtShortDateDay
Dim dtShortDateYear

If IsDate(dtShortDate) Then
    dtShortDate = Format(dtShortDate, "dd/mmm/yyyy")
End If

dtShortDateDay = Day(dtShortDate)
If Len(dtShortDateDay) = 1 Then
    dtShortDateDay = "0" & dtShortDateDay
End If
dtShortDateMonth = Month(dtShortDate)
If Len(dtShortDateMonth) = 1 Then
    dtShortDateMonth = "0" & dtShortDateMonth
End If
dtShortDateYear = Year(dtShortDate)

dtStringDate = dtShortDateYear & dtShortDateMonth & dtShortDateDay

ShortDateToStringDate = dtStringDate

End Function
